#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
#include<unordered_set>
#include<unordered_map>
using namespace std;

//无序的K模型哈希表
//哈希表比红黑树效率大多数场景高一丢丢
void test_unordered_set()
{
	unordered_set<int> s;
	s.insert(5);
	s.insert(2); 
	s.insert(6);
	s.insert(1);
	s.insert(4);

	unordered_set<int>::iterator it = s.begin();
	while (it != s.end())
	{
		cout << *it << " ";
		++it;
	}
	cout << endl;
}
//无序的KV模型哈希表
void test_unordered_map()
{
	unordered_map<string, string> dict;
	dict["sort"];				//插入
	dict["sort"] = "排序";		//修改
	dict["string"] = "字符串";	
	dict["abc"] = "xx";
	unordered_map<string, string>::iterator it = dict.begin();
	while (it != dict.end())
	{
		cout << it->first << ":"<<it->second<<endl;
		++it;
	}
	cout << endl;
}
int main()
{
	test_unordered_set();
	test_unordered_map();
}